//题目链接：https://www.luogu.com.cn/problem/P3375#submit
#include <iostream>
#include <string>
using namespace std;
const int N = 1000010;
int ne[N];

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    int n = s1.size() , m = s2.size();
    s1 = ' ' + s1;
    s2 = ' ' + s2;
    for(int i = 2 , j = 0 ; i <= m ; ++i)
    {
        while(j && s2[i] != s2[j+1]) j = ne[j];
        if(s2[i] == s2[j+1]) ++j;
        ne[i] = j;
    }
    for(int i = 1 , j = 0 ; i <= n ; ++i)
    {
        while(j && s1[i] != s2[j+1]) j = ne[j];
        if(s1[i] == s2[j+1]) ++j;
        if(j == m) printf("%d\n",i-m+1);
    }
    for(int i = 1 ; i <= m ; ++i) printf("%d ",ne[i]);
    return 0;
}